public class MoodForm : UserControl
{
    private ComboBox cmbMoodType;
    private TrackBar trackMoodScore;
    private Label[] scoreLabels;  // 添加分数标签数组
    private Label lblWeather;
    private RichTextBox txtContent;
    private Button btnSave;

    public MoodForm()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        this.BackColor = Color.FromArgb(245, 247, 250);  // 设置浅色背景
        this.Dock = DockStyle.Fill;
        this.Padding = new Padding(30);  // 添加内边距

        var contentPanel = new Panel
        {
            Dock = DockStyle.Fill,
            BackColor = Color.White,
            Padding = new Padding(20),
            AutoScroll = true
        };

        // 心情类型选择
        var lblMoodType = new Label
        {
            Text = "今天的心情",
            Font = new Font("Microsoft YaHei", 14, FontStyle.Bold),
            ForeColor = Color.FromArgb(64, 64, 64),
            AutoSize = true
        };

        cmbMoodType = new ComboBox
        {
            Width = 200,
            Height = 35,
            DropDownStyle = ComboBoxStyle.DropDownList,
            Font = new Font("Microsoft YaHei", 12),
            FlatStyle = FlatStyle.Flat
        };
        cmbMoodType.Items.AddRange(new string[] { "😊 开心", "😌 平静", "😢 难过", "😠 生气", "😰 焦虑" });
        cmbMoodType.SelectedIndex = 0;

        // 心情评分区域
        var scorePanel = new Panel
        {
            BackColor = Color.FromArgb(250, 250, 250),
            Padding = new Padding(15),
            Height = 120,
            Dock = DockStyle.Top,
            Margin = new Padding(0, 20, 0, 20)
        };

        var lblScore = new Label
        {
            Text = "心情指数",
            Font = new Font("Microsoft YaHei", 12, FontStyle.Bold),
            ForeColor = Color.FromArgb(64, 64, 64),
            AutoSize = true
        };

        trackMoodScore = new TrackBar
        {
            Width = 400,
            Minimum = 1,
            Maximum = 5,
            Value = 3,
            TickFrequency = 1,
            TickStyle = TickStyle.Both,
            BackColor = Color.FromArgb(250, 250, 250)
        };

        // 创建分数标签
        scoreLabels = new Label[5];
        var scoreTexts = new[] { "非常差", "较差", "一般", "不错", "很棒" };
        var scoreColors = new[] {
            Color.FromArgb(255, 99, 71),   // 红色
            Color.FromArgb(255, 165, 0),   // 橙色
            Color.FromArgb(72, 190, 117),  // 绿色
            Color.FromArgb(46, 139, 87),   // 深绿色
            Color.FromArgb(34, 139, 34)    // 森林绿
        };

        for (int i = 0; i < 5; i++)
        {
            scoreLabels[i] = new Label
            {
                Text = $"{i + 1}分 - {scoreTexts[i]}",
                AutoSize = true,
                Font = new Font("Microsoft YaHei", 10),
                ForeColor = i == 2 ? scoreColors[i] : Color.Gray  // 默认选中3分
            };
            scorePanel.Controls.Add(scoreLabels[i]);
            scoreLabels[i].Location = new Point(trackMoodScore.Left + (i * 95), trackMoodScore.Bottom + 5);
        }

        trackMoodScore.ValueChanged += (s, e) =>
        {
            // 更新所有分数标签的颜色
            for (int i = 0; i < scoreLabels.Length; i++)
            {
                scoreLabels[i].ForeColor = (i + 1 == trackMoodScore.Value) ? 
                    scoreColors[i] : Color.Gray;
            }
        };

        // 天气显示
        lblWeather = new Label
        {
            Text = "当前天气：晴",
            Font = new Font("Microsoft YaHei", 12),
            ForeColor = Color.FromArgb(64, 64, 64),
            BackColor = Color.FromArgb(250, 250, 250),
            Padding = new Padding(15),
            AutoSize = true
        };

        // 日记内容
        var lblContent = new Label
        {
            Text = "记录此刻的心情...",
            Font = new Font("Microsoft YaHei", 12, FontStyle.Bold),
            ForeColor = Color.FromArgb(64, 64, 64),
            AutoSize = true
        };

        txtContent = new RichTextBox
        {
            Height = 200,
            Font = new Font("Microsoft YaHei", 11),
            BorderStyle = BorderStyle.None,
            BackColor = Color.FromArgb(250, 250, 250),
            Dock = DockStyle.Top,
            Margin = new Padding(0, 10, 0, 20)
        };

        // 保存按钮
        btnSave = new Button
        {
            Text = "保存心情",
            Width = 150,
            Height = 45,
            Font = new Font("Microsoft YaHei", 12, FontStyle.Bold),
            BackColor = Color.FromArgb(72, 190, 117),
            ForeColor = Color.White,
            FlatStyle = FlatStyle.Flat,
            Cursor = Cursors.Hand
        };
        btnSave.FlatAppearance.BorderSize = 0;

        // 使用TableLayoutPanel布局
        var layout = new TableLayoutPanel
        {
            Dock = DockStyle.Fill,
            ColumnCount = 1,
            RowCount = 7,
            AutoSize = true
        };

        layout.Controls.Add(lblMoodType, 0, 0);
        layout.Controls.Add(cmbMoodType, 0, 1);
        layout.Controls.Add(scorePanel, 0, 2);
        layout.Controls.Add(lblWeather, 0, 3);
        layout.Controls.Add(lblContent, 0, 4);
        layout.Controls.Add(txtContent, 0, 5);
        layout.Controls.Add(btnSave, 0, 6);

        contentPanel.Controls.Add(layout);
        this.Controls.Add(contentPanel);
    }
} 